

import UIKit
import KeychainSwift
class XWKeyChainManager: NSObject {
    static let shared = XWKeyChainManager.init()
    private let keychain = KeychainSwift(keyPrefix: "XWSurSpeed")
    private let option = KeychainSwiftAccessOptions.accessibleWhenUnlockedThisDeviceOnly
    private let pinKey = "uuid"
    var hasPin: Bool {
        if let _ = getPin() {
            return true
        } else {
            return false
        }
    }
    func getPin() -> String? {
        return keychain.get(pinKey)
    }
    
    func setPin(value: String) {
        keychain.set(value, forKey: pinKey, withAccess: option)
    }
    
    func getValue(for key: String) -> String? {
        return keychain.get(key)
    }
    
    func set(value: String, for key: String) {
        keychain.set(value, forKey: key, withAccess: option)
    }
}
